<template>
  <laker-dialog
    v-model="visible"
    title="风险分析"
    width="900"
    height="900"
    :show-fullscreen="true"
    :show-close="true"
    destroy-on-close
    @closed="$emit('closed')"
  >
    <table class="laker-table">
      <tr>
        <th style="width: 100px">工作票编号</th>
        <th>工作内容</th>
        <th>工作地点</th>
        <th>风险等级</th>
        <th style="width: 50px">风险分析</th>
        <th style="width: 50px">视频监控</th>
        <th style="width: 50px">上岗到位</th>
        <th style="width: 50px">控制措施</th>
      </tr>
      <tr v-for="(item, index) in ttkList" :key="index">
        <td>{{ item.ttkId }}</td>
        <td>{{ item.ttkDsc }}</td>
        <td>{{ item.ttkLoc }}</td>
        <td style="width: 50px" :class="item.fxdj">{{ item.fxdjName }}</td>
        <td style="width: 50px">
          <el-button type="warning" icon="el-icon-more-filled" circle @click="openDetail(item)"></el-button>
        </td>
        <td style="width: 50px">
          <el-button
            type="primary"
            v-if="item.rtspIp"
            icon="el-icon-video-camera"
            circle
            @click="openVideo(item)"
          ></el-button>
        </td>
        <td style="width: 50px">
          <el-button type="success" icon="el-icon-flag" circle @click="openSigninTable(item)"></el-button>
        </td>
        <td style="width: 50px">
          <el-button type="danger" icon="el-icon-document-checked" circle @click="openCheckTable(item)"></el-button>
        </td>
      </tr>
    </table>
  </laker-dialog>

  <RiskAnalysisDialog ref="raDialogRef" v-if="dialog.raDialog" @closed="dialog.raDialog = false"></RiskAnalysisDialog>
  <safe-check-table ref="scTableRef" v-if="dialog.scTable" @closed="dialog.scTable = false"></safe-check-table>
  <signin-table ref="siTableRef" v-if="dialog.siTable" @closed="dialog.siTable = false"></signin-table>
  <monitor-video ref="videoRef" v-if="dialog.video" @closed="dialog.video = false"></monitor-video>
</template>

<script>
import monitorVideo from '@/components/monitorVideo/index.vue'
import LakerDialog from '@/components/lakerDialog/index.vue'
import RiskAnalysisDialog from './RiskAnalysis.vue'
import { dayjs } from 'element-plus'
import SafeCheckTable from './SafeCheckTable.vue'
import SigninTable from './SigninTable.vue'

export default {
  name: 'RiskTop10',
  components: { LakerDialog, RiskAnalysisDialog, SafeCheckTable, SigninTable, monitorVideo },
  emits: ['success', 'closed'],
  data() {
    return {
      dialog: {
        raDialog: false,
        scTable: false,
        siTable: false,
        video: false
      },
      mode: 'add',
      visible: false,
      titleMap: {
        add: '选择设备类型',
        edit: '编辑人员',
        show: '查看'
      },
      elmain: 'elmain',
      today: dayjs().format('YYYY-MM-DD'),
      risk01: 0,
      ttkList: [
        {
          ttkId: '热机202407-0054',
          ttkType: '热机工作票',
          ttkDsc: '热机工作票',
          ttkSta: '进行中',
          ttkBegDate: '2024-07-01',
          ttkLoc: '13米平台',
          cstNam: '生技部',
          cstGroup: '热工班组',
          zyfx: '密闭空间',
          fxkz: '50',
          fxdj: 'VH',
          fxdjName: '较大风险',
          fromIp: '10.10.100.5',
          rtspIp: '10.10.210.80',
          rtspChannel: 2001
        },
        {
          ttkId: '热机202407-0055',
          ttkType: '热机工作票',
          ttkDsc: '热机工作票',
          ttkSta: '进行中',
          ttkBegDate: '2024-07-01',
          ttkLoc: '13米平台',
          cstNam: '生技部',
          cstGroup: '热工班组',
          zyfx: '密闭空间',
          fxkz: '50',
          fxdj: 'H',
          fxdjName: '较大风险',
          fromIp: '10.10.100.5',
          rtspIp: '10.10.210.80',
          rtspChannel: 2001
        },
        {
          ttkId: '热机202407-0056',
          ttkType: '热机工作票',
          ttkDsc: '热机工作票',
          ttkSta: '进行中',
          ttkBegDate: '2024-07-01',
          ttkLoc: '13米平台',
          cstNam: '生技部',
          cstGroup: '热工班组',
          zyfx: '密闭空间',
          fxkz: '50',
          fxdj: 'N',
          fxdjName: '较大风险',
          fromIp: '10.10.100.5',
          rtspIp: '10.10.210.80',
          rtspChannel: 2001
        },
        {
          ttkId: '热机202407-0057',
          ttkType: '热机工作票',
          ttkDsc: '热机工作票',
          ttkSta: '进行中',
          ttkBegDate: '2024-07-01',
          ttkLoc: '13米平台',
          cstNam: '生技部',
          cstGroup: '热工班组',
          zyfx: '密闭空间',
          fxkz: '50',
          fxdj: 'L',
          fxdjName: '较大风险',
          fromIp: '',
          rtspIp: '',
          rtspChannel: 0
        }
      ]
    }
  },
  methods: {
    //显示
    open(mode = 'add') {
      this.mode = mode
      this.visible = true
      return this
    },
    close() {
      this.visible = false
      return this
    },
    //表单注入数据
    setData(data) {
      console.log(data)
    },
    openDetail(item) {
      this.dialog.raDialog = true
      this.$nextTick(() => {
        this.$refs.raDialogRef.open('show').setData(item)
      })
    },
    openCheckTable(item) {
      this.dialog.scTable = true
      this.$nextTick(() => {
        this.$refs.scTableRef.open('show').setData(item)
      })
    },
    openSigninTable(item) {
      this.dialog.siTable = true
      this.$nextTick(() => {
        this.$refs.siTableRef.open('show').setData(item)
      })
    },
    openVideo(item) {
      this.dialog.video = true
      this.$nextTick(() => {
        this.$refs.videoRef.open('show').setData(item)
      })
    }
  }
}
</script>

<style scoped lang="scss"></style>
